package com.evola.rm.model
{
	import mx.collections.ListCollectionView;

	[Bindable]
	public class Project
	{
		public static const DEFAULT_MISSING_VALUE : String = "???";

		public var name:String;
		
		public var missingValue : String = DEFAULT_MISSING_VALUE;
		public var languages:ListCollectionView;
		public var aliases:ListCollectionView;

		public function Project()
		{
		}

		public function getAlias(expression:String):Alias
		{

			for each (var alias:Alias in aliases)
			{

				if (alias.code == expression)
					return alias;
			}

			return null;
		}

		/**
		 * Metoda vraca alias za pocetak expression-a.
		 */
		public function getAliasStarting(expression:String):Alias
		{

			var foundAlias:Alias=null;

			for each (var alias:Alias in aliases)
			{

				if (expression.indexOf(alias.code) == 0)
				{

					if (!foundAlias || foundAlias.code.length < alias.code.length)
						foundAlias=alias;
				}
			}

			return foundAlias;
		}
	}
}
